import gtk


def Menu(name, *children):
    obj = gtk.Menu()
    for child in children:
        obj.append(child)
    obj2 = gtk.MenuItem(name)
    obj2.set_submenu(obj)
    obj2.show()
    return obj2

def PopupMenu(*children):
    obj = gtk.Menu()
    for child in children:
        obj.append(child)
    return obj

def MenuItem(name, action, keybinding = None, accel_group = None):
    obj = gtk.MenuItem(name)
    if action is not None:
        obj.connect("activate", action, None)
    if keybinding:
        key, mod = gtk.accelerator_parse(keybinding)
        obj.add_accelerator("activate", accel_group, key, mod, gtk.ACCEL_VISIBLE)
    obj.show()
    return obj

def MenuSep():
    obj = gtk.SeparatorMenuItem()
    obj.show()
    return obj

def MenuBar(*menus):
    obj = gtk.MenuBar()
    for mitem in menus:
        obj.append(mitem)
    obj.show()
    return obj

